package com.example.hanchen.yongkanggy.utils;

import java.util.Map;
import java.util.TreeMap;

/*字典升序排序*/

public class TreeMapUtils {
    public static String getTreeMap(Map<String, String> map) {
        // 使用TreeMap自动按键（字典序）升序排序
        Map<String, String> sortedMap = new TreeMap<>(map);
        StringBuilder stringBuilder = new StringBuilder();

        // 输出排序后的Map
        for (Map.Entry<String, String> entry : sortedMap.entrySet()) {
            stringBuilder.append(entry.getKey()).append("=").append(entry.getValue()).append("&");
        }
        return stringBuilder.toString();
    }
}
